package abc.com.abc.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;

import abc.com.abc.R;
import abc.com.abc.bean.MSGBean;
import abc.com.abc.bean.UserBean;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>{

    private Context context;
    private List<MSGBean> mlist;
    //private List<UserBean> list;

    public MyAdapter(Context context,List list){
        this.context = context;
        this.mlist = list;
       // this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.msg, parent, false);
        return new ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {

        MSGBean bean = mlist.get(position);
        holder.msg_get_user.setText(bean.receiver);
        holder.msg_send_user.setText(bean.userName);
        holder.msg_msg.setText(bean.msg);

      //  UserBean bean1 = list.get(position);
       // holder.msg_send_name.setText(bean1.name);

    }

    @Override
    public int getItemCount() {
        return mlist.size();
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        TextView msg_send_user;
        TextView msg_msg;
        TextView msg_get_user;
        TextView msg_send_name;

        public ViewHolder(View itemView) {
            super(itemView);
            msg_send_user = itemView.findViewById(R.id.msg_send_user);
            msg_msg = itemView.findViewById(R.id.msg_msg);
            msg_get_user = itemView.findViewById(R.id.msg_get_user);
            msg_send_name = itemView.findViewById(R.id.msg_send_name);
        }

    }


}
